import javax.swing.*;
import java.awt.event.*;
import java.io.File;

final class SaveAllItem extends AbstractAction{
  private final Doer frame;
  SaveAllItem(String name,Doer frame){
    super(name);
    this.frame=frame;
    putValue(SHORT_DESCRIPTION,name);
    String iconFileName="images"+File.separator+name+".gif";
    if(new File(iconFileName).exists())putValue(SMALL_ICON,new ImageIcon(iconFileName));
  }

  public void actionPerformed(ActionEvent e){
    int i=0;
    while(i<=frame.getTab().getTabCount()-1){
      if(!((InterWindow)(frame.getTab().getComponentAt(i))).isSaved()){
         frame.getTab().setSelectedIndex(i);
	 frame.getSaveItem().saveFile();
      }
      i++;
    }
  }
}
